package javaCode.chapter09.static_.StaticExercise;

public class StaticExercise03 {
    public static void main(String[] args) {
        P.setTotalPerson(3); //3
        new P(); //3+1=4

        P.showTotal();
    }
}

class P{
    private int id;
    private static int total = 0;
    public static void setTotalPerson(int total){
        //this.total = total; 错误，在静态方法中 不能使用this 和 super 关键字
        P.total = total;
    }

    public P() {
        total++;
        id = total;
    }

    public static void showTotal(){
        System.out.println(P.total);
    }
}
